#include "stdafx.h"

int is_whitespace(char c) {	
	return c == ' ' || c == '\n' || c == '\t';
}

void trim(char *dst, char *source) {
	int begin = 0;
	int end = strlen(source)-1;
	int i;
	for(; begin < end; ++begin) {
		if(!is_whitespace(source[begin])) break;
	}

	for(; end > begin; --end) {
		if(!is_whitespace(source[end])) break;
	}

	for(i = begin; i <= end; ++i) {
		dst[i-begin] = source[i];
	}
	dst[i-begin] = 0;
}